package exo1;

/**
 * Created with IntelliJ IDEA.
 * User: naberrad
 * Date: 14/10/13
 * Time: 14:27
 * To change this template use File | Settings | File Templates.
 */
public class Point3D extends Point2D {

    private double z;

    public Point3D(double x, double y, double z) {
        super(x, y);
        this.z = z;
    }

    public double getZ() {
        return z;
    }

    public void setZ(double z) {
        this.z = z;
    }


    public void translate(double x, double y, double z) {
        super.setX(super.getX() + x);
        super.setY(super.getY() + y);
        this.z = this.z + z;
    }

    @Override
    public boolean isOrigin() {
        if (super.isOrigin() && this.z == 0) {
            return true;
        } else {
            return false;
        }
    }

    public double distance(Point3D p3d) {
        double d;
        d=Math.pow(p3d.getX()-this.getX(),2)+Math.pow(p3d.getY()-this.getY(),2)+
                Math.pow(p3d.z-this.z,2);
        d=Math.sqrt(d);
        return d;
    }
}
